package com.dilean.spring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class AplicationContextHolder
{
    private AnnotationConfigApplicationContext context = null;
    private static AplicationContextHolder holder;

    public synchronized static AplicationContextHolder getInstance()
    {
        if (holder == null)
            holder = new AplicationContextHolder();

        return holder;
    }

    public ApplicationContext getContext()
    {
        if (context == null)
            synchronized (this)
            {
                if (context == null)
                {
                    context = new AnnotationConfigApplicationContext(AplicationConfig.class);
                }
            }

        return context;
    }

}
